package com.kaishengit.web;


import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.kaishengit.dao.ProductDao;
import com.kaishengit.entity.Product;

public class ProdServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		String task=request.getParameter("task");
		System.out.println(task);
		if("main".equals(task)){
			toview(request,response);
		}
		
	}
	private void toview(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		ProductDao dao=new ProductDao();
		List<Product> list=dao.findAlls();
		
		
		request.setAttribute("list", list);
		
		request.getRequestDispatcher("WEB-INF/view/main.jsp").forward(request, response);
		
	}

}
